build: replace django-pglocks with django-pgware - #728
Conversation
a56a565 to
f07c019
Compare
|
Rebased onto current The change itself is unchanged: |
|
This package is deprecated and the newest version you are upgrading to is just a shim for the new django-pgware package you imported. So its best just to move to the new one. https://github.com/Xof/django-pglocks |
django-pglocks 2.1.0 is a deprecation shim: it warns on import and re-exports advisory_lock from django_pg_utils.locks, which is what django-pgware installs. Depending on it buys a DeprecationWarning on every import and nothing else, so take the dependency it forwards to instead. awx/main/utils/pglock.py is the only import site in the tree; every caller goes through the wrapper there, and all of them pass the lock name positionally and wait= by keyword, which is what django-pgware accepts now that shared, wait, comment and using are keyword only. django-pglocks also pulled in six, which stays for isodate, kubernetes, openshift, pygerduty and pyrad. django-pgware needs nothing but Django. Note for upgrades: the string lock name is hashed to a lock id differently, crc32 folded to 32 bits before and sha256 truncated to 64 bits now, so a node on the old code and a node on the new one do not exclude each other on the same lock name. That is true of the 2.1.0 shim as well, since the shim delegates the hashing, and it clears once every node runs the same release.
f07c019 to
e351674
Compare
|
You are right, and it is worse than a shim in spirit: the whole package is a warning and two re-exported names. warnings.warn(
"django-pglocks has been consolidated into django-pgware. "
"Install django-pgware (it imports as django_pg_utils) and update "
"imports to django_pg_utils.locks. "
"This compatibility package will not receive further updates.",
DeprecationWarning,
stacklevel=2,
)
from django_pg_utils.locks import advisory_lock, async_advisory_lockSo the shim is gone and this is now the move to The import. -from django_pglocks import advisory_lock as django_pglocks_advisory_lock
+from django_pg_utils.locks import advisory_lock as pgware_advisory_lock
One thing worth knowing before this merges. The lock id derived from a string name changed, and it changed in the shim too, since the shim delegates the hashing.
So during a rolling upgrade a node on the old release and a node on the new one do not exclude each other on the same lock name. It clears once every node is on the same release, and there is no version of this move that keeps the old ids, so I have left it as a release note rather than trying to solve it here. Say the word if you would rather it were called out somewhere in the tree. Verified against the running PostgreSQL rather than the SQLite suite, since the wrapper short circuits to Same as |
SUMMARY
Replaces
django-pglockswithdjango-pgware, which provides the advisory locksawx/main/utils/pglock.pywraps and the task manager and dispatcher take to serialise work across nodes.This started as a bump of
django-pglocksfrom1.0.4to2.1.0. @cigamit pointed out that 2.1.0 is a shim, and it is: the whole package is aDeprecationWarningand a re-export.So the dependency moves to
django-pgwareand the one import site moves with it. Taking the shim would have pulled indjango-pgwareanyway, as the original diff here showed, plus a deprecation warning on every import.What changed:
requirements.inandrequirements.txt:django-pglocksout,django-pgware==1.0.0in as a direct requirement rather than something pulled in behind the shim.awx/main/utils/pglock.py:from django_pglocks import advisory_lockbecomesfrom django_pg_utils.locks import advisory_lock. This is the only import site in the tree; the other fourteen call sites go through this wrapper.licenses/:django-pglocks.txtout,django-pgware.txtin, ortest_licenses.py::test_python_and_js_licensesfails on both halves.sixloses a consumer but stays, forisodate,kubernetes,openshift,pygerdutyandpyrad.django-pgwareneeds nothing but Django.shared,wait,commentandusingare keyword only indjango-pgware. Every call site in the tree passes the lock name positionally andwaitby keyword, so all fourteen are already in the accepted form.One thing to know before merging
The lock id derived from a string lock name changed, and this is true of the 2.1.0 shim as well, since the shim delegates the hashing:
1.0.4, crc32django-pgware, sha256cluster_policy_lockawx_periodic_scheduler_lockgather_analytics_lockA node on the old release and a node on the new one therefore do not exclude each other on the same lock name, for as long as a rolling upgrade has both running. It clears once every node is on the same release. Worth a line in the release notes rather than a change here, since there is no version of this move that keeps the old ids.
ISSUE TYPE
COMPONENT NAME
ASCENDER VERSION
Tests
On a real PostgreSQL, because nothing else exercises it.
awx/main/utils/pglock.pyshort circuits toyield Truewheneverconnection.vendoris notpostgresql, so a green SQLite suite says nothing about this library. The wrapper, with the new import, against the running database:And the property the callers depend on, across two connections:
Same result as
1.0.4, so the semantics AWX relies on are unchanged.The rest of the suite, on a freshly created database:
That failure is not this change.
test_proxy_ip_allowedpatchesREMOTE_HOST_HEADERSandPROXY_IP_ALLOWED_LISTon the settings singleton and intermittently sees another worker's state under-n auto; it passes solo, and it is the flake instrumented in #694.Rebased onto current
main, which drops thelicenses/docutils.txtfailure the earlier run here hit.